package view.progress
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	
	import subumbo.leg.model.Lib;
	import subumbo.leg.model.vo.ResizeVO;
	import subumbo.leg.view.ViewComponent;

	public class Progress extends ViewComponent {
		
		private var _itemText:TextField;
		private var _bar:MovieClip;
		private var _box:MovieClip;
		
		public function Progress():void {
			_box  = Lib.getMovieClip("ProgressBox");
			_bar = _box.bar;
			_itemText = _box.txt;
			addChild(_box);
		}
		
		public override function update(data:Object):void {
			_itemText.text = data.toString();
			_bar.scaleX = 0;
		}
		
		public function setProgress(progress:Number):void {
			_bar.scaleX = progress;
		}
		
		public override function resize(resizeVO:ResizeVO):void {
			_box.x = resizeVO.centerX;
			_box.y = resizeVO.centerY; 
		}
		
		public override function destroy():void {
			super.destroy();
			removeChild(_box);
			_box = null;
			_bar = null;
			_itemText = null;
		}
	}
}